import {defineStore} from "pinia";
import {type} from "../model/type";

export const useFileStore = defineStore('file', {
    state: () => {
        return {
            // ctx 当前菜单操作对象
            ctx: {} as type.FileNode,
            // max 节点标签最大宽度
            maxWidth: 0,
            files: [] as type.FileNode[]
        }
    },
    getters: {},
    actions: {
        setFiles(arr: type.FileNode[]) {
            this.files = arr
        },
        UpdateCtx(ctx: type.FileNode) {
            this.ctx = ctx
        },
        UpdateMaxWidth(width: number) {
            if (width >= this.maxWidth) {
                this.maxWidth = width
            }
        }
    }
})
